<template>
  <div class="menu_container">
    <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
      <el-menu-item index='/FrTrade/c2cTrade'> <span>承兑交易</span></el-menu-item>
      <!-- <el-menu-item index='/Moneytodig'>大宗交易</el-menu-item> -->
      <!-- <el-menu-item index='/FrTrade/otcTrade'><span> OTC Desk</span></el-menu-item> -->
    </el-menu>
    <div class="right_topmenu">
      <div>
        <p><i class="el-icon-data-line "></i>教程</p>
      </div>
      <div class="" @click="toShopLink()" v-show="this.userData.isLogin"> 
        <p>发布广告</p>
      </div>
      <div v-show="this.userData.isLogin" >
        <p :class="indexList=='2'?'active':''" @click='navigateTo("/FrTrade/C2CTrade_list")'>承兑交易订单</p>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "Top-aside",
  data() {
    return {
      userData: this.userModel,
      showLoading: true,
      TGurl:'',
      activeIndex: '/FrTrade/c2cTrade',
      userShopType:'',
      indexList:'1',
    };
  },
  mounted() {
      this.showLoading = true;
      let curlink=this.$route.path;
      console.log(this.indexList);
      if(curlink=='/FrTrade/C2CTrade_list'){
        this.indexList='2';
      }
     // 检测商户
     if (!this.userData.isLogin) {
        console.log('商户top菜单',123);
        // this.errMsg("ptxt119" || "请登录后发布商户广告");
        return false;
      }else{
        this.checkusermerchant();
      };
  },
  methods: {
    handleSelect(key) {
      this.navigateTo(key);
    },
    // 检测是不是商户
    checkusermerchant(){
      return this.request(this.api.checkusermerchant,).then(res => {
        if (res.code == "0") {
          this.userShopType=res.data[0].state;
          console.log(this.userShopType);
          
        }else{
          this.errMsg(res.msg);
          return
      }
      
      })
      
    },
    toShopLink(){
       console.log(this.userData.isLogin);
      if (this.userData.isLogin) {
        console.log('--=----'+this.userShopType);
        // 资格审核中：verify；是商户：enable；商户资格被禁用：disable；不是商户：overrule）
        if(this.userShopType=='verify'){
          this.errMsg('商户资格审核认证中'|| "提示");
          this.$notify.info({
            title: '提示',
            message: '商户资格审核认证中',
            type: 'warning',
          });
          return
          // this.navigateTo("/");
        }else if(this.userShopType=='enable'){
          this.successMsg("你已经是商户，赶快发广告吧!");
          this.navigateTo("/FrTrade/shoporder");
          return
        }else if(this.userShopType=='disable'){
          this.$notify.info({
            title: '提示',
            message: '商户资格被禁用',
            type: 'warning',
          });
          return
        }else if(this.userShopType=='overrule'){
          this.$notify.info({
            title: '提示',
            message: '你还不是商户',
            type: 'warning'
          });
          this.$confirm('您需要先申请并获得广告发布权限, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.navigateTo("/FrTrade/business");
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '已取消'
              });          
            });
          return
        }
        // this.errMsg("label120" || "请登录后操作");
        // return false;
      }else{
        return
      }
      
    }
  }
};
</script>
<style lang="scss" scoped>
.menu_container {
  min-height: calc(100% - 294px);
  padding: 30px 0 2px 0;
  width: 77%;
  margin: 0 auto;
  position: relative;
  .right_topmenu{
    display: flex;
    color: #87a2cd;
    font-size: 16px;
    position: absolute;
    right: 0;
    bottom: 20px;
    >div{
      margin: 0 15px;cursor: pointer;
      i{margin-right: 10px;}
      &:hover{color: #ffffff;}
    }
  }
}
</style>
